<template>
    <div style="height: 80px; display: flex;  font-size: 12px; border-bottom: solid 1px #d7d1d1;">
        <div style="display: inline-block ">
            <i v-bind:class="menu_fold"
               v-on:click="updateCollapse"
               style="font-size: 25px ;line-height: 80px; cursor: pointer"></i>
        </div>
        <div style="flex: 2; padding-left: 20px;" >
            <el-breadcrumb separator="/"  >
                <el-breadcrumb-item v-for="item in address">{{item}}</el-breadcrumb-item>
            </el-breadcrumb>
        </div>

        <el-dropdown style="width: 165px; cursor: pointer;pointer-events: auto;line-height: 80px;font-size: 18px;height: 50px;">
            <span >
                <el-avatar :src="avatar" style=""></el-avatar>
                {{user.username}}<i class="el-icon-arrow-down" style="margin-left: 5px;font-size: 15px;"></i>
            </span>

            <el-dropdown-menu slot="dropdown" style="text-align: center">
                <el-dropdown-item style="font-size: 18px;">
                    <router-link to="/profile" style="color: black;text-decoration: none;" >个人信息</router-link>
                </el-dropdown-item>
                <el-dropdown-item style="font-size: 18px">
                    <span @click="logout">注销</span>
                </el-dropdown-item>
            </el-dropdown-menu>
        </el-dropdown>
    </div>
</template>

<script>
    import request from "@/utils/request";
    import store from "@/store";
    import router, {resetRoute} from "@/router";

    export default {
        name: "Header",
        data() {
            return {
                // address:[]
                user:{},
            }
        },
        props:{
            menu_fold: String,
            updateCollapse: Function,
            avatar:String
        },
        // mounted() {
        //     this.address = localStorage.getItem("currentAddress").split('/');
        // },
        computed:{
            address(){
                return this.$store.state.currentIconState;
            }
        },
        created() {
            this.user = JSON.parse(localStorage.getItem("user"));
        },

        watch:{
            address(newVal,oldVal){
                console.log(newVal);
            }
            // '$route':function () {
            //     this.address = localStorage.getItem("currentAddress").split('/');
            // }
        },
        methods:{
            logout(){
                // localStorage.removeItem("user");
                // this.$router.push("/login");
                // this.$message.success("注销成功");
                store.commit("layout");
                this.$router.push("/login");
                this.$message.success("请重新登录！");
                resetRoute();
                console.log(router.getRoutes());
            },
        }


    }

</script>

<style scoped>
    .el-header {
        border-bottom: #e3d7d7 solid 1px;
        color: #333333;
        line-height: 80px;
    }
    .el-avatar {
        width: 50px;
        height: 50px;
        position: relative;
        right: -2px;
        top: 18px;
    }







</style>